package org.example.config;

import org.example.bean.MyBean;
import org.example.bean.MyClass;
import org.example.controller.IndexController;
import org.example.infoproperties.InfoProperties;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

@Configuration
//如果配置了自定义的属性类，需要通过该注解引入
@EnableConfigurationProperties(value = {InfoProperties.class})
//如果存在该类
@ConditionalOnClass(value = {MyClass.class})
@AutoConfigureAfter(value = {AfterConfig.class})
public class IndexConfig {

    @Resource
    private InfoProperties infoProperties;

    @Bean
    public IndexController getIndexController() {
        return new IndexController(infoProperties);
    }

}
